package com.wl.cloud.backboot.controller;

import com.wl.cloud.backboot.service.TokenService;
import com.wl.cloud.core.dto.RestResultDTO;
import com.wl.cloud.security.model.LoginUserDetails;
import com.wl.cloud.system.support.utils.ConstantSystem;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: wanglin
 * @date: 2024-03-13 周三
 * @Version: 1.0
 * @Description:
 */
@Tag(name = "token接口", description = "TokenController")
@Validated
@CrossOrigin
@RestController
@RequestMapping(value = ConstantSystem.PROJECT_URL_PREFIX + "token")
public class TokenController {

    @Autowired
    private TokenService tokenService;

    @Operation(summary = "获取登录用户")
    @RequestMapping(value = "getLoginUser", method = {RequestMethod.POST, RequestMethod.GET})
    public RestResultDTO<LoginUserDetails> getLoginUser(String token) {
        return RestResultDTO.newSuccess(tokenService.getLoginUser(token));
    }
}
